/*
* Copyright (C) 2020 ~ 2024 chaigec All Rights Reserved.
*
* Author:     chaigec <chaigec@163.com>
* Maintainer: chaigec <chaigec@163.com>

 * Use of this source code is governed by MIT license that can be found in the
 * LICENSE file in the root of the source tree. All contributing project authors
 * may be found in the AUTHORS file in the root of the source tree.
*/

#ifndef MK_SIP_TRANSACTION_H
#define MK_SIP_TRANSACTION_H
#include "MkSipMessage.h"
#include "MkSipHeader.h"
#include "MkUtil/MkTime.h"

class MkApi CMkSipTransaction
{
public:
    typedef enum _transaction_type
    {
        InviteCaller,           //this send request      
        InviteCallee,           //this recv request
        NotInviteCaller,
        NotInviteCallee
    }MkSipTransactionType;
public:
    CMkSipTransaction();
    virtual ~CMkSipTransaction();

    void SetRequest(const CMkSipMessage& SipRequest);
    void SetLastResponse(const CMkSipMessage& SipResponse);
    void SetAck(const CMkSipMessage& SipAck) { m_Ack = SipAck; m_CompleteTime = NowMkTime; }
    void SetType(const MkSipTransactionType& TransType) { m_Type = TransType; }

    const MkSipTransactionType& GetType() const { return m_Type; }
    const CMkSipMessage& GetRequest() const { return m_Request; }
    const CMkSipMessage& GetLastResponse() const { return m_LastResponse; }
    const CMkSipMessage& GetAck() const { return m_Ack; }
    const CMkTime& GetCreateTime() const { return m_CreateTime; }
    const CMkTime& GetCompleteTime() const { return m_CompleteTime; }
protected:
private:
    MkSipTransactionType    m_Type;
    CMkSipMessage           m_Request;
    CMkSipMessage           m_LastResponse;
    CMkSipMessage           m_Ack;

    CMkTime                 m_CreateTime;
    CMkTime                 m_CompleteTime;
};

#endif